package com.org.gsc.zsqdemos.uis;

import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.app.FragmentActivity;
import android.support.v4.view.ViewPager;

import com.org.gsc.zsqdemos.R;
import com.org.gsc.zsqdemos.adapters.MypstAdapter1;

/**
 * Created by qundui on 2017/6/17.
 */

public class TabDemo extends FragmentActivity {
    private TabLayout tabLayout;
    private ViewPager viewPager;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.tabdemo);
        tabLayout= (TabLayout) findViewById(R.id.tab);
        viewPager= (ViewPager) findViewById(R.id.vp);

       tabLayout.addTab(tabLayout.newTab().setText("个性推荐"));
        tabLayout.addTab(tabLayout.newTab().setText("歌单"));
        tabLayout.addTab(tabLayout.newTab().setText("主播电台"));
        tabLayout.addTab(tabLayout.newTab().setText("排行榜"));

        viewPager.setAdapter(new MypstAdapter1(getSupportFragmentManager()));

        tabLayout.setupWithViewPager(viewPager);

        tabLayout.getTabAt(0).setText("个性推荐");
        tabLayout.getTabAt(1).setText("歌单");
        tabLayout.getTabAt(2).setText("主播电台");
        tabLayout.getTabAt(3).setText("排行榜");


    }
}
